package com.kun.dynamic.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author kun.li
 */
@ConfigurationProperties(DynamicDataSourceProperties.PREFIX)
@Data
public class DynamicDataSourceProperties {
    public static final String PREFIX = "spring.datasource.dynamic";
    /**
     * 必须设置默认的库,默认master
     */
    private String primary = "master";
    private String username;

    private String password;

    private String url;

    private String driverClassName;
    private Class<?> type;

    @NestedConfigurationProperty
    private Map<String, DataSourceProperties> dataSource = new LinkedHashMap<>();


    @Data
    public static class DataSourceProperties {
        private String username;

        private String password;

        private String url;

        private String driverClassName;
    }


}
